import 'package:common/common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../../theme/font.dart';

/// @description:
/// @author
/// @date: 2025-01-21 14:28:41
class WalletHistoryPage extends StatefulWidget {
  const WalletHistoryPage({Key? key, required this.inorout}) : super(key: key);
  final String inorout;

  @override
  State<WalletHistoryPage> createState() => _WalletHistoryPageState();
}

class _WalletHistoryPageState extends State<WalletHistoryPage> {
  @override
  void initState() {
    super.initState();
    fetchCoinLogs();
  }

// inorout  -1为全部0支出1收入
  void fetchCoinLogs() {
    HttpProvider.get('/funs/getCoinLogs', params: {'inorout': widget.inorout}, explain: '平台币收支明细记录');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: ListView.separated(
        itemBuilder: (BuildContext context, int index) {
          return _buildItem(name: '', image: '', sex: index % 1);
        },
        separatorBuilder: (BuildContext context, int index) {
          return Divider(height: 0.5, color: const Color(0xFFEEEEEE).withOpacity(0), indent: 15, endIndent: 15);
        },
        itemCount: 10,
      ),
    );
  }

  Widget _buildItem({required String image, required String name, required int sex}) {
    return Container(
      color: Colors.transparent,
      padding: const EdgeInsets.symmetric(horizontal: 16),
      child: Column(
        children: [
          Container(
            padding: const EdgeInsets.symmetric(vertical: 10),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('喵喵小姐',
                        style: TextStyle(color: Colors.white, fontSize: 16.sp, fontWeight: AppFontWeight.medium)),
                    const SizedBox(width: 5),
                    Text('-30',
                        style: TextStyle(color: Colors.white, fontSize: 16.sp, fontWeight: AppFontWeight.medium)),
                  ],
                ),
                const SizedBox(height: 10),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('2024-10-15 17:53:32', style: TextStyle(color: const Color(0xFF999999), fontSize: 13.sp)),
                    Text('剩余金币：100', style: TextStyle(color: const Color(0xFF25D4D0), fontSize: 13.sp)),
                  ],
                ),
              ],
            ),
          ),
          const Divider(color: Color(0xFF5D5454), height: 0.5, indent: 5, endIndent: 5)
        ],
      ),
    );
  }
}
